home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Tools / MPW / flex 2.4.6 / parse.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-01-21  |  42.4 KB  |  1,721 lines  |  [TEXT/MPS ]

  1.  
  2. /*  A Bison parser, made from :parse.y with Bison version GNU Bison version 1.22
  3.   */
  4.  
  5. #define YYBISON 1  /* Identify Bison output.  */
  6.  
  7. #define    CHAR    258
  8. #define    NUMBER    259
  9. #define    SECTEND    260
  10. #define    SCDECL    261
  11. #define    XSCDECL    262
  12. #define    WHITESPACE    263
  13. #define    NAME    264
  14. #define    PREVCCL    265
  15. #define    EOF_OP    266
  16.  
  17. #line 5 ":parse.y"
  18.  
  19. /*-
  20.  * Copyright (c) 1990 The Regents of the University of California.
  21.  * All rights reserved.
  22.  *
  23.  * This code is derived from software contributed to Berkeley by
  24.  * Vern Paxson.
  25.  * 
  26.  * The United States Government has rights in this work pursuant
  27.  * to contract no. DE-AC03-76SF00098 between the United States
  28.  * Department of Energy and the University of California.
  29.  *
  30.  * Redistribution and use in source and binary forms are permitted provided
  31.  * that: (1) source distributions retain this entire copyright notice and
  32.  * comment, and (2) distributions including binaries display the following
  33.  * acknowledgement:  ``This product includes software developed by the
  34.  * University of California, Berkeley and its contributors'' in the
  35.  * documentation or other materials provided with the distribution and in
  36.  * all advertising materials mentioning features or use of this software.
  37.  * Neither the name of the University nor the names of its contributors may
  38.  * be used to endorse or promote products derived from this software without
  39.  * specific prior written permission.
  40.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
  41.  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  42.  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  43.  */
  44.  
  45. /* $Header: /home/daffy/u0/vern/flex/RCS/parse.y,v 2.15 93/12/09 13:57:23 vern Exp $ */
  46.  
  47.  
  48. /* Some versions of bison are broken in that they use alloca() but don't
  49.  * declare it properly.  The following is the patented (just kidding!)
  50.  * #ifdef chud to fix the problem, courtesy of Francois Pinard.
  51.  */
  52. #ifdef YYBISON
  53. /* AIX requires this to be the first thing in the file.  */
  54. #ifdef __GNUC__
  55. #define alloca __builtin_alloca
  56. #else /* not __GNUC__ */
  57. #if HAVE_ALLOCA_H
  58. #include <alloca.h>
  59. #else /* not HAVE_ALLOCA_H */
  60. #ifdef _AIX
  61.  #pragma alloca
  62. #else /* not _AIX */
  63. char *alloca ();
  64. #endif /* not _AIX */
  65. #endif /* not HAVE_ALLOCA_H */
  66. #endif /* not __GNUC__ */
  67. #endif /* YYBISON */
  68.  
  69. /* Bletch, ^^^^ that was ugly! */
  70.  
  71.  
  72. #include "flexdef.h"
  73.  
  74. int pat, scnum, eps, headcnt, trailcnt, anyccl, lastchar, i, actvp, rulelen;
  75. int trlcontxt, xcluflg, cclsorted, varlength, variable_trail_rule;
  76. int *active_ss;
  77. Char clower();
  78. void build_eof_action();
  79. void yyerror();
  80.  
  81. static int madeany = false;  /* whether we've made the '.' character class */
  82. int previous_continued_action;    /* whether the previous rule's action was '|' */
  83.  
  84. /* On some over-ambitious machines, such as DEC Alpha's, the default
  85.  * token type is "long" instead of "int"; this leads to problems with
  86.  * declaring yylval in flexdef.h.  But so far, all the yacc's I've seen
  87.  * wrap their definitions of YYSTYPE with "#ifndef YYSTYPE"'s, so the
  88.  * following should ensure that the default token type is "int".
  89.  */
  90. #define YYSTYPE int
  91.  
  92.  
  93. #ifndef YYLTYPE
  94. typedef
  95.   struct yyltype
  96.     {
  97.       int timestamp;
  98.       int first_line;
  99.       int first_column;
  100.       int last_line;
  101.       int last_column;
  102.       char *text;
  103.    }
  104.   yyltype;
  105.  
  106. #define YYLTYPE yyltype
  107. #endif
  108.  
  109. #ifndef YYSTYPE
  110. #define YYSTYPE int
  111. #endif
  112. #include <stdio.h>
  113.  
  114. #ifndef __cplusplus
  115. #if !defined(__STDC__) && !defined(macintosh)
  116. #define const
  117. #endif
  118. #endif
  119.  
  120.  
  121.  
  122. #define    YYFINAL        85
  123. #define    YYFLAG        -32768
  124. #define    YYNTBASE    32
  125.  
  126. #define YYTRANSLATE(x) ((unsigned)(x) <= 266 ? yytranslate[x] : 53)
  127.  
  128. static const char yytranslate[] = {     0,
  129.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  130.      2,     2,    12,     2,     2,     2,     2,     2,     2,     2,
  131.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  132.      2,     2,     2,    26,     2,    18,     2,     2,     2,    27,
  133.     28,    16,    21,    17,    31,    25,    20,     2,     2,     2,
  134.      2,     2,     2,     2,     2,     2,     2,     2,     2,    14,
  135.      2,    15,    22,     2,     2,     2,     2,     2,     2,     2,
  136.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  137.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  138.     29,     2,    30,    13,     2,     2,     2,     2,     2,     2,
  139.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  140.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  141.      2,     2,    23,    19,    24,     2,     2,     2,     2,     2,
  142.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  143.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  144.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  145.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  146.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  147.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  148.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  149.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  150.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  151.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  152.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  153.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  154.      2,     2,     2,     2,     2,     1,     2,     3,     4,     5,
  155.      6,     7,     8,     9,    10,    11
  156. };
  157.  
  158. #if YYDEBUG != 0
  159. static const short yyprhs[] = {     0,
  160.      0,     6,     7,    13,    14,    17,    19,    21,    23,    27,
  161.     29,    31,    36,    37,    38,    42,    45,    48,    50,    53,
  162.     55,    57,    61,    65,    69,    70,    73,    75,    77,    80,
  163.     84,    87,    89,    93,    95,    98,   101,   103,   106,   109,
  164.    112,   119,   125,   130,   132,   134,   136,   140,   144,   146,
  165.    150,   155,   160,   163,   164,   167
  166. };
  167.  
  168. static const short yyrhs[] = {    33,
  169.     34,    35,    38,    39,     0,     0,    34,    36,     8,    37,
  170.     12,     0,     0,     1,    12,     0,     5,     0,     6,     0,
  171.      7,     0,    37,     8,     9,     0,     9,     0,     1,     0,
  172.     38,    39,    40,    12,     0,     0,     0,    41,    13,    45,
  173.      0,    41,    45,     0,    13,    45,     0,    45,     0,    41,
  174.     11,     0,    11,     0,     1,     0,    14,    42,    15,     0,
  175.     14,    16,    15,     0,    42,    17,    44,     0,     0,    43,
  176.     44,     0,     1,     0,     9,     0,    47,    46,     0,    47,
  177.     46,    18,     0,    46,    18,     0,    46,     0,    46,    19,
  178.     48,     0,    48,     0,    46,    20,     0,    48,    49,     0,
  179.     49,     0,    49,    16,     0,    49,    21,     0,    49,    22,
  180.      0,    49,    23,     4,    17,     4,    24,     0,    49,    23,
  181.      4,    17,    24,     0,    49,    23,     4,    24,     0,    25,
  182.      0,    50,     0,    10,     0,    26,    52,    26,     0,    27,
  183.     46,    28,     0,     3,     0,    29,    51,    30,     0,    29,
  184.     13,    51,    30,     0,    51,     3,    31,     3,     0,    51,
  185.      3,     0,     0,    52,     3,     0,     0
  186. };
  187.  
  188. #endif
  189.  
  190. #if YYDEBUG != 0
  191. static const short yyrline[] = { 0,
  192.     82,   111,   124,   125,   126,   130,   143,   146,   150,   153,
  193.    156,   160,   161,   164,   175,   195,   206,   230,   241,   244,
  194.    263,   267,   269,   278,   280,   282,   282,   286,   307,   362,
  195.    365,   408,   426,   432,   437,   464,   472,   476,   483,   489,
  196.    495,   523,   537,   556,   578,   596,   603,   606,   609,   620,
  197.    623,   630,   658,   669,   677,   687
  198. };
  199.  
  200. static const char * const yytname[] = {   "$","error","$illegal.","CHAR","NUMBER",
  201. "SECTEND","SCDECL","XSCDECL","WHITESPACE","NAME","PREVCCL","EOF_OP","'\\n'",
  202. "'^'","'<'","'>'","'*'","','","'$'","'|'","'/'","'+'","'?'","'{'","'}'","'.'",
  203. "'\"'","'('","')'","'['","']'","'-'","goal","initlex","sect1","sect1end","startconddecl",
  204. "namelist1","sect2","initforrule","flexrule","scon","namelist2","@1","sconname",
  205. "rule","re","re2","series","singleton","fullccl","ccl","string",""
  206. };
  207. #endif
  208.  
  209. static const short yyr1[] = {     0,
  210.     32,    33,    34,    34,    34,    35,    36,    36,    37,    37,
  211.     37,    38,    38,    39,    40,    40,    40,    40,    40,    40,
  212.     40,    41,    41,    42,    43,    42,    42,    44,    45,    45,
  213.     45,    45,    46,    46,    47,    48,    48,    49,    49,    49,
  214.     49,    49,    49,    49,    49,    49,    49,    49,    49,    50,
  215.     50,    51,    51,    51,    52,    52
  216. };
  217.  
  218. static const short yyr2[] = {     0,
  219.      5,     0,     5,     0,     2,     1,     1,     1,     3,     1,
  220.      1,     4,     0,     0,     3,     2,     2,     1,     2,     1,
  221.      1,     3,     3,     3,     0,     2,     1,     1,     2,     3,
  222.      2,     1,     3,     1,     2,     2,     1,     2,     2,     2,
  223.      6,     5,     4,     1,     1,     1,     3,     3,     1,     3,
  224.      4,     4,     2,     0,     2,     0
  225. };
  226.  
  227. static const short yydefact[] = {     2,
  228.      0,     0,     0,     5,     6,     7,     8,    13,     0,    14,
  229.      0,     0,    11,    10,     0,    21,    49,    46,    20,     0,
  230.      0,    44,    56,     0,    54,     0,     0,    18,    32,     0,
  231.     34,    37,    45,     0,     3,    17,    27,     0,     0,     0,
  232.      0,     0,    54,     0,    12,    19,     0,    16,    31,     0,
  233.     35,    29,    36,    38,    39,    40,     0,     9,    23,    22,
  234.      0,    28,    26,    55,    47,    48,     0,    53,    50,    15,
  235.     33,    30,     0,    24,    51,     0,     0,    43,    52,     0,
  236.     42,    41,     0,     0,     0
  237. };
  238.  
  239. static const short yydefgoto[] = {    83,
  240.      1,     3,     8,     9,    15,    10,    12,    26,    27,    39,
  241.     40,    63,    28,    29,    30,    31,    32,    33,    44,    41
  242. };
  243.  
  244. static const short yypact[] = {-32768,
  245.     61,    -2,    64,-32768,-32768,-32768,-32768,-32768,    13,-32768,
  246.     34,     1,-32768,-32768,    30,-32768,-32768,-32768,-32768,    21,
  247.     48,-32768,-32768,    21,    31,    33,    26,-32768,    54,    21,
  248.     21,    38,-32768,    47,-32768,-32768,-32768,    43,     5,    56,
  249.     15,   -11,-32768,     2,-32768,-32768,    21,-32768,-32768,    21,
  250. -32768,    57,    38,-32768,-32768,-32768,    59,-32768,-32768,-32768,
  251.     56,-32768,-32768,-32768,-32768,-32768,     4,    46,-32768,-32768,
  252.     21,-32768,    -8,-32768,-32768,    75,    -1,-32768,-32768,    55,
  253. -32768,-32768,    80,    81,-32768
  254. };
  255.  
  256. static const short yypgoto[] = {-32768,
  257. -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
  258. -32768,    22,   -14,    -5,-32768,    32,   -31,-32768,    41,-32768
  259. };
  260.  
  261.  
  262. #define    YYLAST        84
  263.  
  264.  
  265. static const short yytable[] = {    53,
  266.     -1,    16,    80,    17,    68,    36,    68,    50,    77,     4,
  267.     18,    19,    48,    20,    21,    78,    66,    64,    42,    60,
  268.     11,    61,    81,    17,    52,    22,    23,    24,    17,    25,
  269.     18,    69,    70,    75,    13,    18,    46,    34,    47,    53,
  270.     65,    35,    14,    43,    45,    22,    23,    24,    37,    25,
  271.     22,    23,    24,    54,    25,    58,   -25,    59,    55,    56,
  272.     57,     2,    73,    38,    62,    -4,    -4,    -4,     5,     6,
  273.      7,    49,    50,    51,    72,    50,    76,    79,    82,    84,
  274.     85,    71,    74,    67
  275. };
  276.  
  277. static const short yycheck[] = {    31,
  278.      0,     1,     4,     3,     3,    20,     3,    19,    17,    12,
  279.     10,    11,    27,    13,    14,    24,    28,     3,    24,    15,
  280.      8,    17,    24,     3,    30,    25,    26,    27,     3,    29,
  281.     10,    30,    47,    30,     1,    10,    11,     8,    13,    71,
  282.     26,    12,     9,    13,    12,    25,    26,    27,     1,    29,
  283.     25,    26,    27,    16,    29,     9,     9,    15,    21,    22,
  284.     23,     1,     4,    16,     9,     5,     6,     7,     5,     6,
  285.      7,    18,    19,    20,    18,    19,    31,     3,    24,     0,
  286.      0,    50,    61,    43
  287. };
  288. /* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
  289. #line 3 "{BISON_SKEL_DIR}bison.simple"
  290.  
  291. /* Skeleton output parser for bison,
  292.    Copyright (C) 1984, 1989, 1990 Bob Corbett and Richard Stallman
  293.  
  294.    This program is free software; you can redistribute it and/or modify
  295.    it under the terms of the GNU General Public License as published by
  296.    the Free Software Foundation; either version 1, or (at your option)
  297.    any later version.
  298.  
  299.    This program is distributed in the hope that it will be useful,
  300.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  301.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  302.    GNU General Public License for more details.
  303.  
  304.    You should have received a copy of the GNU General Public License
  305.    along with this program; if not, write to the Free Software
  306.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  307.  
  308. /* Modified for Macintosh MPW
  309.    Franklin Chen
  310.    Fri, Mar 19, 1993    Used <string.h> memcpy(); for MPW C, allow use of
  311.        malloc() instead of alloca()
  312.    Sat, Dec 18, 1993    Added alloca.h */
  313.     
  314. #ifndef alloca
  315. #ifdef __GNUC__
  316. #define alloca __builtin_alloca
  317. #else /* not GNU C.  */
  318. #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || defined (macintosh)
  319. #include <alloca.h>
  320. #else /* not sparc */
  321. #if defined (MSDOS) && !defined (__TURBOC__)
  322. #include <malloc.h>
  323. #else /* not MSDOS, or __TURBOC__ */
  324. #if defined(_AIX)
  325. #include <malloc.h>
  326.  #pragma alloca
  327. #else /* not MSDOS, __TURBOC__, or _AIX */
  328. #ifdef __hpux
  329. #ifdef __cplusplus
  330. extern "C" {
  331. void *alloca (unsigned int);
  332. };
  333. #else /* not __cplusplus */
  334. void *alloca ();
  335. #endif /* not __cplusplus */
  336. #endif /* __hpux */
  337. #endif /* not _AIX */
  338. #endif /* not MSDOS, or __TURBOC__ */
  339. #endif /* not sparc.  */
  340. #endif /* not GNU C.  */
  341. #endif /* alloca not defined.  */
  342.  
  343. /* This is the parser code that is written into each bison parser
  344.   when the %semantic_parser declaration is not specified in the grammar.
  345.   It was written by Richard Stallman by simplifying the hairy parser
  346.   used when %semantic_parser is specified.  */
  347.  
  348. /* Note: there must be only one dollar sign in this file.
  349.    It is replaced by the list of actions, each action
  350.    as one case of the switch.  */
  351.  
  352. #define yyerrok        (yyerrstatus = 0)
  353. #define yyclearin    (yychar = YYEMPTY)
  354. #define YYEMPTY        -2
  355. #define YYEOF        0
  356. #define YYACCEPT    return(0)
  357. #define YYABORT     return(1)
  358. #define YYERROR        goto yyerrlab1
  359. /* Like YYERROR except do call yyerror.
  360.    This remains here temporarily to ease the
  361.    transition to the new meaning of YYERROR, for GCC.
  362.    Once GCC version 2 has supplanted version 1, this can go.  */
  363. #define YYFAIL        goto yyerrlab
  364. #define YYRECOVERING()  (!!yyerrstatus)
  365. #define YYBACKUP(token, value) \
  366. do                                \
  367.   if (yychar == YYEMPTY && yylen == 1)                \
  368.     { yychar = (token), yylval = (value);            \
  369.       yychar1 = YYTRANSLATE (yychar);                \
  370.       YYPOPSTACK;                        \
  371.       goto yybackup;                        \
  372.     }                                \
  373.   else                                \
  374.     { yyerror ("syntax error: cannot back up"); YYERROR; }    \
  375. while (0)
  376.  
  377. #define YYTERROR    1
  378. #define YYERRCODE    256
  379.  
  380. #ifndef YYPURE
  381. #define YYLEX        yylex()
  382. #endif
  383.  
  384. #ifdef YYPURE
  385. #ifdef YYLSP_NEEDED
  386. #define YYLEX        yylex(&yylval, &yylloc)
  387. #else
  388. #define YYLEX        yylex(&yylval)
  389. #endif
  390. #endif
  391.  
  392. /* If nonreentrant, generate the variables here */
  393.  
  394. #ifndef YYPURE
  395.  
  396. int    yychar;            /*  the lookahead symbol        */
  397. YYSTYPE    yylval;            /*  the semantic value of the        */
  398.                 /*  lookahead symbol            */
  399.  
  400. #ifdef YYLSP_NEEDED
  401. YYLTYPE yylloc;            /*  location data for the lookahead    */
  402.                 /*  symbol                */
  403. #endif
  404.  
  405. int yynerrs;            /*  number of parse errors so far       */
  406. #endif  /* not YYPURE */
  407.  
  408. #if YYDEBUG != 0
  409. int yydebug;            /*  nonzero means print parse trace    */
  410. /* Since this is uninitialized, it does not stop multiple parsers
  411.    from coexisting.  */
  412. #endif
  413.  
  414. /*  YYINITDEPTH indicates the initial size of the parser's stacks    */
  415.  
  416. #ifndef    YYINITDEPTH
  417. #define YYINITDEPTH 200
  418. #endif
  419.  
  420. /*  YYMAXDEPTH is the maximum size the stacks can grow to
  421.     (effective only if the built-in stack extension method is used).  */
  422.  
  423. #if YYMAXDEPTH == 0
  424. #undef YYMAXDEPTH
  425. #endif
  426.  
  427. #ifndef YYMAXDEPTH
  428. #define YYMAXDEPTH 10000
  429. #endif
  430.  
  431. /* Prevent warning if -Wstrict-prototypes.  */
  432. #if defined(__GNUC__) || defined(macintosh)
  433. int yyparse (void);
  434. #endif
  435.  
  436. #if __GNUC__ > 1        /* GNU C and GNU C++ define this.  */
  437. #define __yy_bcopy(FROM,TO,COUNT)    __builtin_memcpy(TO,FROM,COUNT)
  438. #else                /* not GNU C or C++ */
  439. #ifdef macintosh
  440. #include <string.h>    /* Why not just use library function? */
  441. #define __yy_bcopy(FROM,TO,COUNT)    memcpy(TO,FROM,COUNT)
  442. #else    /* ! macintosh */
  443. #ifndef __cplusplus
  444.  
  445. /* This is the most reliable way to avoid incompatibilities
  446.    in available built-in functions on various systems.  */
  447. static void
  448. __yy_bcopy (from, to, count)
  449.      char *from;
  450.      char *to;
  451.      int count;
  452. {
  453.   register char *f = from;
  454.   register char *t = to;
  455.   register int i = count;
  456.  
  457.   while (i-- > 0)
  458.     *t++ = *f++;
  459. }
  460.  
  461. #else /* __cplusplus */
  462.  
  463. /* This is the most reliable way to avoid incompatibilities
  464.    in available built-in functions on various systems.  */
  465. static void
  466. __yy_bcopy (char *from, char *to, int count)
  467. {
  468.   register char *f = from;
  469.   register char *t = to;
  470.   register int i = count;
  471.  
  472.   while (i-- > 0)
  473.     *t++ = *f++;
  474. }
  475.  
  476. #endif
  477. #endif    /* ! macintosh */
  478. #endif
  479.  
  480. #line 194 "{BISON_SKEL_DIR}bison.simple"
  481. int
  482. yyparse()
  483. {
  484.   register int yystate;
  485.   register int yyn;
  486.   register short *yyssp;
  487.   register YYSTYPE *yyvsp;
  488.   int yyerrstatus;    /*  number of tokens to shift before error messages enabled */
  489.   int yychar1 = 0;        /*  lookahead token as an internal (translated) token number */
  490.  
  491.   short    yyssa[YYINITDEPTH];    /*  the state stack            */
  492.   YYSTYPE yyvsa[YYINITDEPTH];    /*  the semantic value stack        */
  493.  
  494.   short *yyss = yyssa;        /*  refer to the stacks thru separate pointers */
  495.   YYSTYPE *yyvs = yyvsa;    /*  to allow yyoverflow to reallocate them elsewhere */
  496.  
  497. #ifdef YYLSP_NEEDED
  498.   YYLTYPE yylsa[YYINITDEPTH];    /*  the location stack            */
  499.   YYLTYPE *yyls = yylsa;
  500.   YYLTYPE *yylsp;
  501.  
  502. #define YYPOPSTACK   (yyvsp--, yyssp--, yylsp--)
  503. #else
  504. #define YYPOPSTACK   (yyvsp--, yyssp--)
  505. #endif
  506.  
  507.   int yystacksize = YYINITDEPTH;
  508.  
  509. #ifdef YYPURE
  510.   int yychar;
  511.   YYSTYPE yylval;
  512.   int yynerrs;
  513. #ifdef YYLSP_NEEDED
  514.   YYLTYPE yylloc;
  515. #endif
  516. #endif
  517.  
  518.   YYSTYPE yyval;        /*  the variable used to return        */
  519.                 /*  semantic values from the action    */
  520.                 /*  routines                */
  521.  
  522.   int yylen;
  523.  
  524. #if YYDEBUG != 0
  525.   if (yydebug)
  526.     fprintf(stderr, "Starting parse\n");
  527. #endif
  528.  
  529.   yystate = 0;
  530.   yyerrstatus = 0;
  531.   yynerrs = 0;
  532.   yychar = YYEMPTY;        /* Cause a token to be read.  */
  533.  
  534.   /* Initialize stack pointers.
  535.      Waste one element of value and location stack
  536.      so that they stay on the same level as the state stack.
  537.      The wasted elements are never initialized.  */
  538.  
  539.   yyssp = yyss - 1;
  540.   yyvsp = yyvs;
  541. #ifdef YYLSP_NEEDED
  542.   yylsp = yyls;
  543. #endif
  544.  
  545. /* Push a new state, which is found in  yystate  .  */
  546. /* In all cases, when you get here, the value and location stacks
  547.    have just been pushed. so pushing a state here evens the stacks.  */
  548. yynewstate:
  549.  
  550.   *++yyssp = yystate;
  551.  
  552.   if (yyssp >= yyss + yystacksize - 1)
  553.     {
  554.       /* Give user a chance to reallocate the stack */
  555.       /* Use copies of these so that the &'s don't force the real ones into memory. */
  556.       YYSTYPE *yyvs1 = yyvs;
  557.       short *yyss1 = yyss;
  558. #ifdef YYLSP_NEEDED
  559.       YYLTYPE *yyls1 = yyls;
  560. #endif
  561.  
  562.       /* Get the current used size of the three stacks, in elements.  */
  563.       int size = yyssp - yyss + 1;
  564.  
  565. #ifdef yyoverflow
  566.       /* Each stack pointer address is followed by the size of
  567.      the data in use in that stack, in bytes.  */
  568. #ifdef YYLSP_NEEDED
  569.       /* This used to be a conditional around just the two extra args,
  570.      but that might be undefined if yyoverflow is a macro.  */
  571.       yyoverflow("parser stack overflow",
  572.          &yyss1, size * sizeof (*yyssp),
  573.          &yyvs1, size * sizeof (*yyvsp),
  574.          &yyls1, size * sizeof (*yylsp),
  575.          &yystacksize);
  576. #else
  577.       yyoverflow("parser stack overflow",
  578.          &yyss1, size * sizeof (*yyssp),
  579.          &yyvs1, size * sizeof (*yyvsp),
  580.          &yystacksize);
  581. #endif
  582.  
  583.       yyss = yyss1; yyvs = yyvs1;
  584. #ifdef YYLSP_NEEDED
  585.       yyls = yyls1;
  586. #endif
  587. #else /* no yyoverflow */
  588.       /* Extend the stack our own way.  */
  589.       if (yystacksize >= YYMAXDEPTH)
  590.     {
  591.       yyerror("parser stack overflow");
  592.       return 2;
  593.     }
  594.       yystacksize *= 2;
  595.       if (yystacksize > YYMAXDEPTH)
  596.     yystacksize = YYMAXDEPTH;
  597.       yyss = (short *) alloca (yystacksize * sizeof (*yyssp));
  598.       __yy_bcopy ((char *)yyss1, (char *)yyss, size * sizeof (*yyssp));
  599.       yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp));
  600.       __yy_bcopy ((char *)yyvs1, (char *)yyvs, size * sizeof (*yyvsp));
  601. #ifdef YYLSP_NEEDED
  602.       yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp));
  603.       __yy_bcopy ((char *)yyls1, (char *)yyls, size * sizeof (*yylsp));
  604. #endif
  605. #endif /* no yyoverflow */
  606.  
  607.       yyssp = yyss + size - 1;
  608.       yyvsp = yyvs + size - 1;
  609. #ifdef YYLSP_NEEDED
  610.       yylsp = yyls + size - 1;
  611. #endif
  612.  
  613. #if YYDEBUG != 0
  614.       if (yydebug)
  615.     fprintf(stderr, "Stack size increased to %d\n", yystacksize);
  616. #endif
  617.  
  618.       if (yyssp >= yyss + yystacksize - 1)
  619.     YYABORT;
  620.     }
  621.  
  622. #if YYDEBUG != 0
  623.   if (yydebug)
  624.     fprintf(stderr, "Entering state %d\n", yystate);
  625. #endif
  626.  
  627.   goto yybackup;
  628.  yybackup:
  629.  
  630. /* Do appropriate processing given the current state.  */
  631. /* Read a lookahead token if we need one and don't already have one.  */
  632. /* yyresume: */
  633.  
  634.   /* First try to decide what to do without reference to lookahead token.  */
  635.  
  636.   yyn = yypact[yystate];
  637.   if (yyn == YYFLAG)
  638.     goto yydefault;
  639.  
  640.   /* Not known => get a lookahead token if don't already have one.  */
  641.  
  642.   /* yychar is either YYEMPTY or YYEOF
  643.      or a valid token in external form.  */
  644.  
  645.   if (yychar == YYEMPTY)
  646.     {
  647. #if YYDEBUG != 0
  648.       if (yydebug)
  649.     fprintf(stderr, "Reading a token: ");
  650. #endif
  651.       yychar = YYLEX;
  652.     }
  653.  
  654.   /* Convert token to internal form (in yychar1) for indexing tables with */
  655.  
  656.   if (yychar <= 0)        /* This means end of input. */
  657.     {
  658.       yychar1 = 0;
  659.       yychar = YYEOF;        /* Don't call YYLEX any more */
  660.  
  661. #if YYDEBUG != 0
  662.       if (yydebug)
  663.     fprintf(stderr, "Now at end of input.\n");
  664. #endif
  665.     }
  666.   else
  667.     {
  668.       yychar1 = YYTRANSLATE(yychar);
  669.  
  670. #if YYDEBUG != 0
  671.       if (yydebug)
  672.     {
  673.       fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
  674.       /* Give the individual parser a way to print the precise meaning
  675.          of a token, for further debugging info.  */
  676. #ifdef YYPRINT
  677.       YYPRINT (stderr, yychar, yylval);
  678. #endif
  679.       fprintf (stderr, ")\n");
  680.     }
  681. #endif
  682.     }
  683.  
  684.   yyn += yychar1;
  685.   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
  686.     goto yydefault;
  687.  
  688.   yyn = yytable[yyn];
  689.  
  690.   /* yyn is what to do for this token type in this state.
  691.      Negative => reduce, -yyn is rule number.
  692.      Positive => shift, yyn is new state.
  693.        New state is final state => don't bother to shift,
  694.        just return success.
  695.      0, or most negative number => error.  */
  696.  
  697.   if (yyn < 0)
  698.     {
  699.       if (yyn == YYFLAG)
  700.     goto yyerrlab;
  701.       yyn = -yyn;
  702.       goto yyreduce;
  703.     }
  704.   else if (yyn == 0)
  705.     goto yyerrlab;
  706.  
  707.   if (yyn == YYFINAL)
  708.     YYACCEPT;
  709.  
  710.   /* Shift the lookahead token.  */
  711.  
  712. #if YYDEBUG != 0
  713.   if (yydebug)
  714.     fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
  715. #endif
  716.  
  717.   /* Discard the token being shifted unless it is eof.  */
  718.   if (yychar != YYEOF)
  719.     yychar = YYEMPTY;
  720.  
  721.   *++yyvsp = yylval;
  722. #ifdef YYLSP_NEEDED
  723.   *++yylsp = yylloc;
  724. #endif
  725.  
  726.   /* count tokens shifted since error; after three, turn off error status.  */
  727.   if (yyerrstatus) yyerrstatus--;
  728.  
  729.   yystate = yyn;
  730.   goto yynewstate;
  731.  
  732. /* Do the default action for the current state.  */
  733. yydefault:
  734.  
  735.   yyn = yydefact[yystate];
  736.   if (yyn == 0)
  737.     goto yyerrlab;
  738.  
  739. /* Do a reduction.  yyn is the number of a rule to reduce with.  */
  740. yyreduce:
  741.   yylen = yyr2[yyn];
  742.   if (yylen > 0)
  743.     yyval = yyvsp[1-yylen]; /* implement default value of the action */
  744.  
  745. #if YYDEBUG != 0
  746.   if (yydebug)
  747.     {
  748.       int i;
  749.  
  750.       fprintf (stderr, "Reducing via rule %d (line %d), ",
  751.            yyn, yyrline[yyn]);
  752.  
  753.       /* Print the symbols being reduced, and their result.  */
  754.       for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
  755.     fprintf (stderr, "%s ", yytname[yyrhs[i]]);
  756.       fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
  757.     }
  758. #endif
  759.  
  760.  
  761.   switch (yyn) {
  762.  
  763. case 1:
  764. #line 83 ":parse.y"
  765. { /* add default rule */
  766.             int def_rule;
  767.  
  768.             pat = cclinit();
  769.             cclnegate( pat );
  770.  
  771.             def_rule = mkstate( -pat );
  772.  
  773.             /* Remember the number of the default rule so we
  774.              * don't generate "can't match" warnings for it.
  775.              */
  776.             default_rule = num_rules;
  777.  
  778.             finish_rule( def_rule, false, 0, 0 );
  779.  
  780.             for ( i = 1; i <= lastsc; ++i )
  781.                 scset[i] = mkbranch( scset[i], def_rule );
  782.  
  783.             if ( spprdflt )
  784.                 add_action(
  785.                 "YY_FATAL_ERROR( \"flex scanner jammed\" )" );
  786.             else
  787.                 add_action( "ECHO" );
  788.  
  789.             add_action( ";\n\tYY_BREAK\n" );
  790.             ;
  791.     break;}
  792. case 2:
  793. #line 112 ":parse.y"
  794. { /* initialize for processing rules */
  795.  
  796.             /* Create default DFA start condition. */
  797.             scinstal( "INITIAL", false );
  798.  
  799.             /* Initially, the start condition scoping is
  800.              * "no start conditions active".
  801.              */
  802.             actvp = 0;
  803.             ;
  804.     break;}
  805. case 5:
  806. #line 127 ":parse.y"
  807. { synerr( "unknown error processing section 1" ); ;
  808.     break;}
  809. case 6:
  810. #line 131 ":parse.y"
  811. {
  812.             /* We now know how many start conditions there
  813.              * are, so create the "activity" map indicating
  814.              * which conditions are active.
  815.              */
  816.             active_ss = allocate_integer_array( lastsc + 1 );
  817.  
  818.             for ( i = 1; i <= lastsc; ++i )
  819.                 active_ss[i] = 0;
  820.             ;
  821.     break;}
  822. case 7:
  823. #line 144 ":parse.y"
  824. { xcluflg = false; ;
  825.     break;}
  826. case 8:
  827. #line 147 ":parse.y"
  828. { xcluflg = true; ;
  829.     break;}
  830. case 9:
  831. #line 151 ":parse.y"
  832. { scinstal( nmstr, xcluflg ); ;
  833.     break;}
  834. case 10:
  835. #line 154 ":parse.y"
  836. { scinstal( nmstr, xcluflg ); ;
  837.     break;}
  838. case 11:
  839. #line 157 ":parse.y"
  840. { synerr( "bad start condition list" ); ;
  841.     break;}
  842. case 14:
  843. #line 165 ":parse.y"
  844. {
  845.             /* Initialize for a parse of one rule. */
  846.             trlcontxt = variable_trail_rule = varlength = false;
  847.             trailcnt = headcnt = rulelen = 0;
  848.             current_state_type = STATE_NORMAL;
  849.             previous_continued_action = continued_action;
  850.             new_rule();
  851.             ;
  852.     break;}
  853. case 15:
  854. #line 176 ":parse.y"
  855. {
  856.             pat = yyvsp[0];
  857.             finish_rule( pat, variable_trail_rule,
  858.                 headcnt, trailcnt );
  859.  
  860.             for ( i = 1; i <= actvp; ++i )
  861.                 scbol[actvsc[i]] =
  862.                     mkbranch( scbol[actvsc[i]], pat );
  863.  
  864.             if ( ! bol_needed )
  865.                 {
  866.                 bol_needed = true;
  867.  
  868.                 if ( performance_report > 1 )
  869.                     pinpoint_message( 
  870.             "'^' operator results in sub-optimal performance" );
  871.                 }
  872.             ;
  873.     break;}
  874. case 16:
  875. #line 196 ":parse.y"
  876. {
  877.             pat = yyvsp[0];
  878.             finish_rule( pat, variable_trail_rule,
  879.                 headcnt, trailcnt );
  880.  
  881.             for ( i = 1; i <= actvp; ++i )
  882.                 scset[actvsc[i]] =
  883.                     mkbranch( scset[actvsc[i]], pat );
  884.             ;
  885.     break;}
  886. case 17:
  887. #line 207 ":parse.y"
  888. {
  889.             pat = yyvsp[0];
  890.             finish_rule( pat, variable_trail_rule,
  891.                 headcnt, trailcnt );
  892.  
  893.             /* Add to all non-exclusive start conditions,
  894.              * including the default (0) start condition.
  895.              */
  896.  
  897.             for ( i = 1; i <= lastsc; ++i )
  898.                 if ( ! scxclu[i] )
  899.                     scbol[i] = mkbranch( scbol[i], pat );
  900.  
  901.             if ( ! bol_needed )
  902.                 {
  903.                 bol_needed = true;
  904.  
  905.                 if ( performance_report > 1 )
  906.                     pinpoint_message(
  907.             "'^' operator results in sub-optimal performance" );
  908.                 }
  909.             ;
  910.     break;}
  911. case 18:
  912. #line 231 ":parse.y"
  913. {
  914.             pat = yyvsp[0];
  915.             finish_rule( pat, variable_trail_rule,
  916.                 headcnt, trailcnt );
  917.  
  918.             for ( i = 1; i <= lastsc; ++i )
  919.                 if ( ! scxclu[i] )
  920.                     scset[i] = mkbranch( scset[i], pat );
  921.             ;
  922.     break;}
  923. case 19:
  924. #line 242 ":parse.y"
  925. { build_eof_action(); ;
  926.     break;}
  927. case 20:
  928. #line 245 ":parse.y"
  929. {
  930.             /* This EOF applies to all start conditions
  931.              * which don't already have EOF actions.
  932.              */
  933.             actvp = 0;
  934.  
  935.             for ( i = 1; i <= lastsc; ++i )
  936.                 if ( ! sceof[i] )
  937.                     actvsc[++actvp] = i;
  938.  
  939.             if ( actvp == 0 )
  940.                 warn(
  941.             "all start conditions already have <<EOF>> rules" );
  942.  
  943.             else
  944.                 build_eof_action();
  945.             ;
  946.     break;}
  947. case 21:
  948. #line 264 ":parse.y"
  949. { synerr( "unrecognized rule" ); ;
  950.     break;}
  951. case 23:
  952. #line 270 ":parse.y"
  953. {
  954.             actvp = 0;
  955.  
  956.             for ( i = 1; i <= lastsc; ++i )
  957.                 actvsc[++actvp] = i;
  958.             ;
  959.     break;}
  960. case 25:
  961. #line 280 ":parse.y"
  962. { actvp = 0; ;
  963.     break;}
  964. case 27:
  965. #line 283 ":parse.y"
  966. { synerr( "bad start condition list" ); ;
  967.     break;}
  968. case 28:
  969. #line 287 ":parse.y"
  970. {
  971.             if ( (scnum = sclookup( nmstr )) == 0 )
  972.                 format_pinpoint_message(
  973.                     "undeclared start condition %s",
  974.                     nmstr );
  975.             else
  976.                 {
  977.                 if ( ++actvp >= current_max_scs )
  978.                     /* Some bozo has included multiple
  979.                      * instances of start condition names.
  980.                      */
  981.                     pinpoint_message(
  982.                 "too many start conditions in <> construct!" );
  983.  
  984.                 else
  985.                     actvsc[actvp] = scnum;
  986.                 }
  987.             ;
  988.     break;}
  989. case 29:
  990. #line 308 ":parse.y"
  991. {
  992.             if ( transchar[lastst[yyvsp[0]]] != SYM_EPSILON )
  993.                 /* Provide final transition \now/ so it
  994.                  * will be marked as a trailing context
  995.                  * state.
  996.                  */
  997.                 yyvsp[0] = link_machines( yyvsp[0],
  998.                         mkstate( SYM_EPSILON ) );
  999.  
  1000.             mark_beginning_as_normal( yyvsp[0] );
  1001.             current_state_type = STATE_NORMAL;
  1002.  
  1003.             if ( previous_continued_action )
  1004.                 {
  1005.                 /* We need to treat this as variable trailing
  1006.                  * context so that the backup does not happen
  1007.                  * in the action but before the action switch
  1008.                  * statement.  If the backup happens in the
  1009.                  * action, then the rules "falling into" this
  1010.                  * one's action will *also* do the backup,
  1011.                  * erroneously.
  1012.                  */
  1013.                 if ( ! varlength || headcnt != 0 )
  1014.                     warn(
  1015.         "trailing context made variable due to preceding '|' action" );
  1016.  
  1017.                 /* Mark as variable. */
  1018.                 varlength = true;
  1019.                 headcnt = 0;
  1020.                 }
  1021.  
  1022.             if ( lex_compat || (varlength && headcnt == 0) )
  1023.                 { /* variable trailing context rule */
  1024.                 /* Mark the first part of the rule as the
  1025.                  * accepting "head" part of a trailing
  1026.                  * context rule.
  1027.                  *
  1028.                  * By the way, we didn't do this at the
  1029.                  * beginning of this production because back
  1030.                  * then current_state_type was set up for a
  1031.                  * trail rule, and add_accept() can create
  1032.                  * a new state ...
  1033.                  */
  1034.                 add_accept( yyvsp[-1],
  1035.                     num_rules | YY_TRAILING_HEAD_MASK );
  1036.                 variable_trail_rule = true;
  1037.                 }
  1038.             
  1039.             else
  1040.                 trailcnt = rulelen;
  1041.  
  1042.             yyval = link_machines( yyvsp[-1], yyvsp[0] );
  1043.             ;
  1044.     break;}
  1045. case 30:
  1046. #line 363 ":parse.y"
  1047. { synerr( "trailing context used twice" ); ;
  1048.     break;}
  1049. case 31:
  1050. #line 366 ":parse.y"
  1051. {
  1052.             headcnt = 0;
  1053.             trailcnt = 1;
  1054.             rulelen = 1;
  1055.             varlength = false;
  1056.  
  1057.             current_state_type = STATE_TRAILING_CONTEXT;
  1058.  
  1059.             if ( trlcontxt )
  1060.                 {
  1061.                 synerr( "trailing context used twice" );
  1062.                 yyval = mkstate( SYM_EPSILON );
  1063.                 }
  1064.  
  1065.             else if ( previous_continued_action )
  1066.                 {
  1067.                 /* See the comment in the rule for "re2 re"
  1068.                  * above.
  1069.                  */
  1070.                 warn(
  1071.         "trailing context made variable due to preceding '|' action" );
  1072.  
  1073.                 varlength = true;
  1074.                 }
  1075.  
  1076.             if ( lex_compat || varlength )
  1077.                 {
  1078.                 /* Again, see the comment in the rule for
  1079.                  * "re2 re" above.
  1080.                  */
  1081.                 add_accept( yyvsp[-1],
  1082.                     num_rules | YY_TRAILING_HEAD_MASK );
  1083.                 variable_trail_rule = true;
  1084.                 }
  1085.  
  1086.             trlcontxt = true;
  1087.  
  1088.             eps = mkstate( SYM_EPSILON );
  1089.             yyval = link_machines( yyvsp[-1],
  1090.                 link_machines( eps, mkstate( '\n' ) ) );
  1091.             ;
  1092.     break;}
  1093. case 32:
  1094. #line 409 ":parse.y"
  1095. {
  1096.             yyval = yyvsp[0];
  1097.  
  1098.             if ( trlcontxt )
  1099.                 {
  1100.                 if ( lex_compat || (varlength && headcnt == 0) )
  1101.                     /* Both head and trail are
  1102.                      * variable-length.
  1103.                      */
  1104.                     variable_trail_rule = true;
  1105.                 else
  1106.                     trailcnt = rulelen;
  1107.                 }
  1108.             ;
  1109.     break;}
  1110. case 33:
  1111. #line 427 ":parse.y"
  1112. {
  1113.             varlength = true;
  1114.             yyval = mkor( yyvsp[-2], yyvsp[0] );
  1115.             ;
  1116.     break;}
  1117. case 34:
  1118. #line 433 ":parse.y"
  1119. { yyval = yyvsp[0]; ;
  1120.     break;}
  1121. case 35:
  1122. #line 438 ":parse.y"
  1123. {
  1124.             /* This rule is written separately so the
  1125.              * reduction will occur before the trailing
  1126.              * series is parsed.
  1127.              */
  1128.  
  1129.             if ( trlcontxt )
  1130.                 synerr( "trailing context used twice" );
  1131.             else
  1132.                 trlcontxt = true;
  1133.  
  1134.             if ( varlength )
  1135.                 /* We hope the trailing context is
  1136.                  * fixed-length.
  1137.                  */
  1138.                 varlength = false;
  1139.             else
  1140.                 headcnt = rulelen;
  1141.  
  1142.             rulelen = 0;
  1143.  
  1144.             current_state_type = STATE_TRAILING_CONTEXT;
  1145.             yyval = yyvsp[-1];
  1146.             ;
  1147.     break;}
  1148. case 36:
  1149. #line 465 ":parse.y"
  1150. {
  1151.             /* This is where concatenation of adjacent patterns
  1152.              * gets done.
  1153.              */
  1154.             yyval = link_machines( yyvsp[-1], yyvsp[0] );
  1155.             ;
  1156.     break;}
  1157. case 37:
  1158. #line 473 ":parse.y"
  1159. { yyval = yyvsp[0]; ;
  1160.     break;}
  1161. case 38:
  1162. #line 477 ":parse.y"
  1163. {
  1164.             varlength = true;
  1165.  
  1166.             yyval = mkclos( yyvsp[-1] );
  1167.             ;
  1168.     break;}
  1169. case 39:
  1170. #line 484 ":parse.y"
  1171. {
  1172.             varlength = true;
  1173.             yyval = mkposcl( yyvsp[-1] );
  1174.             ;
  1175.     break;}
  1176. case 40:
  1177. #line 490 ":parse.y"
  1178. {
  1179.             varlength = true;
  1180.             yyval = mkopt( yyvsp[-1] );
  1181.             ;
  1182.     break;}
  1183. case 41:
  1184. #line 496 ":parse.y"
  1185. {
  1186.             varlength = true;
  1187.  
  1188.             if ( yyvsp[-3] > yyvsp[-1] || yyvsp[-3] < 0 )
  1189.                 {
  1190.                 synerr( "bad iteration values" );
  1191.                 yyval = yyvsp[-5];
  1192.                 }
  1193.             else
  1194.                 {
  1195.                 if ( yyvsp[-3] == 0 )
  1196.                     {
  1197.                     if ( yyvsp[-1] <= 0 )
  1198.                         {
  1199.                         synerr(
  1200.                         "bad iteration values" );
  1201.                         yyval = yyvsp[-5];
  1202.                         }
  1203.                     else
  1204.                         yyval = mkopt(
  1205.                             mkrep( yyvsp[-5], 1, yyvsp[-1] ) );
  1206.                     }
  1207.                 else
  1208.                     yyval = mkrep( yyvsp[-5], yyvsp[-3], yyvsp[-1] );
  1209.                 }
  1210.             ;
  1211.     break;}
  1212. case 42:
  1213. #line 524 ":parse.y"
  1214. {
  1215.             varlength = true;
  1216.  
  1217.             if ( yyvsp[-2] <= 0 )
  1218.                 {
  1219.                 synerr( "iteration value must be positive" );
  1220.                 yyval = yyvsp[-4];
  1221.                 }
  1222.  
  1223.             else
  1224.                 yyval = mkrep( yyvsp[-4], yyvsp[-2], INFINITY );
  1225.             ;
  1226.     break;}
  1227. case 43:
  1228. #line 538 ":parse.y"
  1229. {
  1230.             /* The singleton could be something like "(foo)",
  1231.              * in which case we have no idea what its length
  1232.              * is, so we punt here.
  1233.              */
  1234.             varlength = true;
  1235.  
  1236.             if ( yyvsp[-1] <= 0 )
  1237.                 {
  1238.                 synerr( "iteration value must be positive" );
  1239.                 yyval = yyvsp[-3];
  1240.                 }
  1241.  
  1242.             else
  1243.                 yyval = link_machines( yyvsp[-3],
  1244.                         copysingl( yyvsp[-3], yyvsp[-1] - 1 ) );
  1245.             ;
  1246.     break;}
  1247. case 44:
  1248. #line 557 ":parse.y"
  1249. {
  1250.             if ( ! madeany )
  1251.                 {
  1252.                 /* Create the '.' character class. */
  1253.                 anyccl = cclinit();
  1254.                 ccladd( anyccl, '\n' );
  1255.                 cclnegate( anyccl );
  1256.  
  1257.                 if ( useecs )
  1258.                     mkeccl( ccltbl + cclmap[anyccl],
  1259.                         ccllen[anyccl], nextecm,
  1260.                         ecgroup, csize, csize );
  1261.  
  1262.                 madeany = true;
  1263.                 }
  1264.  
  1265.             ++rulelen;
  1266.  
  1267.             yyval = mkstate( -anyccl );
  1268.             ;
  1269.     break;}
  1270. case 45:
  1271. #line 579 ":parse.y"
  1272. {
  1273.             if ( ! cclsorted )
  1274.                 /* Sort characters for fast searching.  We
  1275.                  * use a shell sort since this list could
  1276.                  * be large.
  1277.                  */
  1278.                 cshell( ccltbl + cclmap[yyvsp[0]], ccllen[yyvsp[0]], true );
  1279.  
  1280.             if ( useecs )
  1281.                 mkeccl( ccltbl + cclmap[yyvsp[0]], ccllen[yyvsp[0]],
  1282.                     nextecm, ecgroup, csize, csize );
  1283.  
  1284.             ++rulelen;
  1285.  
  1286.             yyval = mkstate( -yyvsp[0] );
  1287.             ;
  1288.     break;}
  1289. case 46:
  1290. #line 597 ":parse.y"
  1291. {
  1292.             ++rulelen;
  1293.  
  1294.             yyval = mkstate( -yyvsp[0] );
  1295.             ;
  1296.     break;}
  1297. case 47:
  1298. #line 604 ":parse.y"
  1299. { yyval = yyvsp[-1]; ;
  1300.     break;}
  1301. case 48:
  1302. #line 607 ":parse.y"
  1303. { yyval = yyvsp[-1]; ;
  1304.     break;}
  1305. case 49:
  1306. #line 610 ":parse.y"
  1307. {
  1308.             ++rulelen;
  1309.  
  1310.             if ( caseins && yyvsp[0] >= 'A' && yyvsp[0] <= 'Z' )
  1311.                 yyvsp[0] = clower( yyvsp[0] );
  1312.  
  1313.             yyval = mkstate( yyvsp[0] );
  1314.             ;
  1315.     break;}
  1316. case 50:
  1317. #line 621 ":parse.y"
  1318. { yyval = yyvsp[-1]; ;
  1319.     break;}
  1320. case 51:
  1321. #line 624 ":parse.y"
  1322. {
  1323.             cclnegate( yyvsp[-1] );
  1324.             yyval = yyvsp[-1];
  1325.             ;
  1326.     break;}
  1327. case 52:
  1328. #line 631 ":parse.y"
  1329. {
  1330.             if ( caseins )
  1331.                 {
  1332.                 if ( yyvsp[-2] >= 'A' && yyvsp[-2] <= 'Z' )
  1333.                     yyvsp[-2] = clower( yyvsp[-2] );
  1334.                 if ( yyvsp[0] >= 'A' && yyvsp[0] <= 'Z' )
  1335.                     yyvsp[0] = clower( yyvsp[0] );
  1336.                 }
  1337.  
  1338.             if ( yyvsp[-2] > yyvsp[0] )
  1339.                 synerr( "negative range in character class" );
  1340.  
  1341.             else
  1342.                 {
  1343.                 for ( i = yyvsp[-2]; i <= yyvsp[0]; ++i )
  1344.                     ccladd( yyvsp[-3], i );
  1345.  
  1346.                 /* Keep track if this ccl is staying in
  1347.                  * alphabetical order.
  1348.                  */
  1349.                 cclsorted = cclsorted && (yyvsp[-2] > lastchar);
  1350.                 lastchar = yyvsp[0];
  1351.                 }
  1352.  
  1353.             yyval = yyvsp[-3];
  1354.             ;
  1355.     break;}
  1356. case 53:
  1357. #line 659 ":parse.y"
  1358. {
  1359.             if ( caseins && yyvsp[0] >= 'A' && yyvsp[0] <= 'Z' )
  1360.                 yyvsp[0] = clower( yyvsp[0] );
  1361.  
  1362.             ccladd( yyvsp[-1], yyvsp[0] );
  1363.             cclsorted = cclsorted && (yyvsp[0] > lastchar);
  1364.             lastchar = yyvsp[0];
  1365.             yyval = yyvsp[-1];
  1366.             ;
  1367.     break;}
  1368. case 54:
  1369. #line 670 ":parse.y"
  1370. {
  1371.             cclsorted = true;
  1372.             lastchar = 0;
  1373.             yyval = cclinit();
  1374.             ;
  1375.     break;}
  1376. case 55:
  1377. #line 678 ":parse.y"
  1378. {
  1379.             if ( caseins && yyvsp[0] >= 'A' && yyvsp[0] <= 'Z' )
  1380.                 yyvsp[0] = clower( yyvsp[0] );
  1381.  
  1382.             ++rulelen;
  1383.  
  1384.             yyval = link_machines( yyvsp[-1], mkstate( yyvsp[0] ) );
  1385.             ;
  1386.     break;}
  1387. case 56:
  1388. #line 688 ":parse.y"
  1389. { yyval = mkstate( SYM_EPSILON ); ;
  1390.     break;}
  1391. }
  1392.    /* the action file gets copied in in place of this dollarsign */
  1393. #line 475 "{BISON_SKEL_DIR}bison.simple"
  1394.  
  1395.   yyvsp -= yylen;
  1396.   yyssp -= yylen;
  1397. #ifdef YYLSP_NEEDED
  1398.   yylsp -= yylen;
  1399. #endif
  1400.  
  1401. #if YYDEBUG != 0
  1402.   if (yydebug)
  1403.     {
  1404.       short *ssp1 = yyss - 1;
  1405.       fprintf (stderr, "state stack now");
  1406.       while (ssp1 != yyssp)
  1407.     fprintf (stderr, " %d", *++ssp1);
  1408.       fprintf (stderr, "\n");
  1409.     }
  1410. #endif
  1411.  
  1412.   *++yyvsp = yyval;
  1413.  
  1414. #ifdef YYLSP_NEEDED
  1415.   yylsp++;
  1416.   if (yylen == 0)
  1417.     {
  1418.       yylsp->first_line = yylloc.first_line;
  1419.       yylsp->first_column = yylloc.first_column;
  1420.       yylsp->last_line = (yylsp-1)->last_line;
  1421.       yylsp->last_column = (yylsp-1)->last_column;
  1422.       yylsp->text = 0;
  1423.     }
  1424.   else
  1425.     {
  1426.       yylsp->last_line = (yylsp+yylen-1)->last_line;
  1427.       yylsp->last_column = (yylsp+yylen-1)->last_column;
  1428.     }
  1429. #endif
  1430.  
  1431.   /* Now "shift" the result of the reduction.
  1432.      Determine what state that goes to,
  1433.      based on the state we popped back to
  1434.      and the rule number reduced by.  */
  1435.  
  1436.   yyn = yyr1[yyn];
  1437.  
  1438.   yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
  1439.   if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
  1440.     yystate = yytable[yystate];
  1441.   else
  1442.     yystate = yydefgoto[yyn - YYNTBASE];
  1443.  
  1444.   goto yynewstate;
  1445.  
  1446. yyerrlab:   /* here on detecting error */
  1447.  
  1448.   if (! yyerrstatus)
  1449.     /* If not already recovering from an error, report this error.  */
  1450.     {
  1451.       ++yynerrs;
  1452.  
  1453. #ifdef YYERROR_VERBOSE
  1454.       yyn = yypact[yystate];
  1455.  
  1456.       if (yyn > YYFLAG && yyn < YYLAST)
  1457.     {
  1458.       int size = 0;
  1459.       char *msg;
  1460.       int x, count;
  1461.  
  1462.       count = 0;
  1463.       /* Start X at -yyn if nec to avoid negative indexes in yycheck.  */
  1464.       for (x = (yyn < 0 ? -yyn : 0);
  1465.            x < (sizeof(yytname) / sizeof(char *)); x++)
  1466.         if (yycheck[x + yyn] == x)
  1467.           size += strlen(yytname[x]) + 15, count++;
  1468.       msg = (char *) malloc(size + 15);
  1469.       if (msg != 0)
  1470.         {
  1471.           strcpy(msg, "parse error");
  1472.  
  1473.           if (count < 5)
  1474.         {
  1475.           count = 0;
  1476.           for (x = (yyn < 0 ? -yyn : 0);
  1477.                x < (sizeof(yytname) / sizeof(char *)); x++)
  1478.             if (yycheck[x + yyn] == x)
  1479.               {
  1480.             strcat(msg, count == 0 ? ", expecting `" : " or `");
  1481.             strcat(msg, yytname[x]);
  1482.             strcat(msg, "'");
  1483.             count++;
  1484.               }
  1485.         }
  1486.           yyerror(msg);
  1487.           free(msg);
  1488.         }
  1489.       else
  1490.         yyerror ("parse error; also virtual memory exceeded");
  1491.     }
  1492.       else
  1493. #endif /* YYERROR_VERBOSE */
  1494.     yyerror("parse error");
  1495.     }
  1496.  
  1497.   goto yyerrlab1;
  1498. yyerrlab1:   /* here on error raised explicitly by an action */
  1499.  
  1500.   if (yyerrstatus == 3)
  1501.     {
  1502.       /* if just tried and failed to reuse lookahead token after an error, discard it.  */
  1503.  
  1504.       /* return failure if at end of input */
  1505.       if (yychar == YYEOF)
  1506.     YYABORT;
  1507.  
  1508. #if YYDEBUG != 0
  1509.       if (yydebug)
  1510.     fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
  1511. #endif
  1512.  
  1513.       yychar = YYEMPTY;
  1514.     }
  1515.  
  1516.   /* Else will try to reuse lookahead token
  1517.      after shifting the error token.  */
  1518.  
  1519.   yyerrstatus = 3;        /* Each real token shifted decrements this */
  1520.  
  1521.   goto yyerrhandle;
  1522.  
  1523. yyerrdefault:  /* current state does not do anything special for the error token. */
  1524.  
  1525. #if 0
  1526.   /* This is wrong; only states that explicitly want error tokens
  1527.      should shift them.  */
  1528.   yyn = yydefact[yystate];  /* If its default is to accept any token, ok.  Otherwise pop it.*/
  1529.   if (yyn) goto yydefault;
  1530. #endif
  1531.  
  1532. yyerrpop:   /* pop the current state because it cannot handle the error token */
  1533.  
  1534.   if (yyssp == yyss) YYABORT;
  1535.   yyvsp--;
  1536.   yystate = *--yyssp;
  1537. #ifdef YYLSP_NEEDED
  1538.   yylsp--;
  1539. #endif
  1540.  
  1541. #if YYDEBUG != 0
  1542.   if (yydebug)
  1543.     {
  1544.       short *ssp1 = yyss - 1;
  1545.       fprintf (stderr, "Error: state stack now");
  1546.       while (ssp1 != yyssp)
  1547.     fprintf (stderr, " %d", *++ssp1);
  1548.       fprintf (stderr, "\n");
  1549.     }
  1550. #endif
  1551.  
  1552. yyerrhandle:
  1553.  
  1554.   yyn = yypact[yystate];
  1555.   if (yyn == YYFLAG)
  1556.     goto yyerrdefault;
  1557.  
  1558.   yyn += YYTERROR;
  1559.   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
  1560.     goto yyerrdefault;
  1561.  
  1562.   yyn = yytable[yyn];
  1563.   if (yyn < 0)
  1564.     {
  1565.       if (yyn == YYFLAG)
  1566.     goto yyerrpop;
  1567.       yyn = -yyn;
  1568.       goto yyreduce;
  1569.     }
  1570.   else if (yyn == 0)
  1571.     goto yyerrpop;
  1572.  
  1573.   if (yyn == YYFINAL)
  1574.     YYACCEPT;
  1575.  
  1576. #if YYDEBUG != 0
  1577.   if (yydebug)
  1578.     fprintf(stderr, "Shifting error token, ");
  1579. #endif
  1580.  
  1581.   *++yyvsp = yylval;
  1582. #ifdef YYLSP_NEEDED
  1583.   *++yylsp = yylloc;
  1584. #endif
  1585.  
  1586.   yystate = yyn;
  1587.   goto yynewstate;
  1588. }
  1589. #line 691 ":parse.y"
  1590.  
  1591.  
  1592.  
  1593. /* build_eof_action - build the "<<EOF>>" action for the active start
  1594.  *                    conditions
  1595.  */
  1596.  
  1597. void build_eof_action()
  1598.     {
  1599.     register int i;
  1600.     char action_text[MAXLINE];
  1601.  
  1602.     for ( i = 1; i <= actvp; ++i )
  1603.         {
  1604.         if ( sceof[actvsc[i]] )
  1605.             format_pinpoint_message(
  1606.                 "multiple <<EOF>> rules for start condition %s",
  1607.                 scname[actvsc[i]] );
  1608.  
  1609.         else
  1610.             {
  1611.             sceof[actvsc[i]] = true;
  1612.             sprintf( action_text, "case YY_STATE_EOF(%s):\n",
  1613.             scname[actvsc[i]] );
  1614.             add_action( action_text );
  1615.             }
  1616.         }
  1617.  
  1618.     line_directive_out( (FILE *) 0 );
  1619.  
  1620.     /* This isn't a normal rule after all - don't count it as
  1621.      * such, so we don't have any holes in the rule numbering
  1622.      * (which make generating "rule can never match" warnings
  1623.      * more difficult.
  1624.      */
  1625.     --num_rules;
  1626.     ++num_eof_rules;
  1627.     }
  1628.  
  1629.  
  1630. /* format_synerr - write out formatted syntax error */
  1631.  
  1632. void format_synerr( msg, arg )
  1633. char msg[], arg[];
  1634.     {
  1635.     char errmsg[MAXLINE];
  1636.  
  1637.     (void) sprintf( errmsg, msg, arg );
  1638.     synerr( errmsg );
  1639.     }
  1640.  
  1641.  
  1642. /* synerr - report a syntax error */
  1643.  
  1644. void synerr( str )
  1645. char str[];
  1646.     {
  1647.     syntaxerror = true;
  1648.     pinpoint_message( str );
  1649.     }
  1650.  
  1651.  
  1652. /* warn - report a warning, unless -w was given */
  1653.  
  1654. void warn( str )
  1655. char str[];
  1656.     {
  1657.     line_warning( str, linenum );
  1658.     }
  1659.  
  1660. /* format_pinpoint_message - write out a message formatted with one string,
  1661.  *                 pinpointing its location
  1662.  */
  1663.  
  1664. void format_pinpoint_message( msg, arg )
  1665. char msg[], arg[];
  1666.     {
  1667.     char errmsg[MAXLINE];
  1668.  
  1669.     (void) sprintf( errmsg, msg, arg );
  1670.     pinpoint_message( errmsg );
  1671.     }
  1672.  
  1673.  
  1674. /* pinpoint_message - write out a message, pinpointing its location */
  1675.  
  1676. void pinpoint_message( str )
  1677. char str[];
  1678.     {
  1679.     line_pinpoint( str, linenum );
  1680.     }
  1681.  
  1682.  
  1683. /* line_warning - report a warning at a given line, unless -w was given */
  1684.  
  1685. void line_warning( str, line )
  1686. char str[];
  1687. int line;
  1688.     {
  1689.     char warning[MAXLINE];
  1690.  
  1691.     if ( ! nowarn )
  1692.         {
  1693.         sprintf( warning, "warning, %s", str );
  1694.         line_pinpoint( warning, line );
  1695.         }
  1696.     }
  1697.  
  1698.  
  1699. /* line_pinpoint - write out a message, pinpointing it at the given line */
  1700.  
  1701. void line_pinpoint( str, line )
  1702. char str[];
  1703. int line;
  1704.     {
  1705. #ifdef MPW
  1706.     fprintf( stderr, "File \"%s\"; Line %d\t# %s\n", infilename, line, str );
  1707. #else
  1708.     fprintf( stderr, "\"%s\", line %d: %s\n", infilename, line, str );
  1709. #endif
  1710.     }
  1711.  
  1712.  
  1713. /* yyerror - eat up an error message from the parser;
  1714.  *         currently, messages are ignore
  1715.  */
  1716.  
  1717. void yyerror( msg )
  1718. char msg[];
  1719.     {
  1720.     }
  1721.